package org.ch04.test00.demo05.breeder;

import org.ch04.test00.demo05.animal.Animal;
import org.ch04.test00.demo05.annotation.StateAnnotation;

/**
 * 饲养员
 * @author CSY
 * @date 2025 - 03 - 31
 */
public class Breeder<T extends Animal> {
    /**
     * 喂养动物
     * @param t 喂养的动物
     */
    public void feed(T t){
        System.out.println("喂养动物...");
    }

    /**
     * 巡查
     * @param clazz 巡查的动物的Class对象
     */
    public void patrol(Class<? extends T> clazz){
        if(clazz.isAnnotationPresent(StateAnnotation.class)){
            StateAnnotation sleepStateAnnotation = clazz.getAnnotation(StateAnnotation.class);
            String sleepState = sleepStateAnnotation.sleepState();
            if(sleepState.equals("失眠")){
                System.out.println("该动物睡眠不好，需要分发安眠药");
            }else{
                System.out.println("该动物睡眠质量良好");
            }
        }
    }

    /**
     * 体检
     * @param clazz 体检的动物的Class对象
     */
    public void checkup(Class<? extends T> clazz){
        if(clazz.isAnnotationPresent(StateAnnotation.class)){
            StateAnnotation healthStateAnnotation = clazz.getAnnotation(StateAnnotation.class);
            String healthState = healthStateAnnotation.healthState();
            if(healthState.equals("差")){
                System.out.println("该动物健康状态不佳，需要特别照看");
            }else{
                System.out.println("该动物健康状态为"+healthState);
            }
        }
    }
}
